package com.example.rpc.request;

import com.example.rpc.test.Serverhandle;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @description:
 * @author: RockyZZB
 * @time: 2020/12/21 20:57
 */
public class ServerRequest {
    public void publishServer() throws IOException {
        ServerSocket serverSocket=new ServerSocket(6666);
        ExecutorService service= Executors.newFixedThreadPool(5);
        while (true){
            System.out.println("wait conn");
            Socket accept = serverSocket.accept();
            System.out.println("success conn");
            service.execute(new Serverhandle(accept));
        }
    }

    public static void main(String[] args) throws IOException {
        ServerRequest request=new ServerRequest();
        request.publishServer();
    }
}
